<?php
require '../script/mysqlconfig.php';
$conn = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
if ($conn->connect_error) {
    die("连接数据库失败: " . $conn->connect_error);
}

//获取用户输入
//$username = isset($_POST['username']) ? $_POST['username'] : 'guest';

$brand = $_POST["brand"];
$model = $_POST["model"];
$serial_number = $_POST["serial_number"];
$device_type = $_POST["device_type"];
$room = $_POST["room"];
$cabinet = $_POST["cabinet"];
$start_u = $_POST["start_u"];
$end_u = $_POST["end_u"];
$device_status = $_POST["device_status"];
$device_feature = $_POST["device_feature"];
$bmc_ip = $_POST["bmc_ip"];
$manage_ip = $_POST["manage_ip"];
$yewu_ip = $_POST["yewu_ip"];
$device_belong = $_POST["device_belong"];
$belong_en = $_POST["belong_en"];
$belong_op = $_POST["belong_op"];
$asset_code = $_POST["asset_code"];
$use_en = $_POST["use_en"];
$use_operator = $_POST["use_operator"];
$client_no = $_POST["client_no"];
$client_name = $_POST["client_name"];
$other = $_POST["other"];

$sql = "INSERT INTO hosts (brand, model, serial_number, device_type, room, cabinet, start_u, end_u, device_status, device_feature, bmc_ip, manage_ip, yewu_ip, device_belong, belong_en, belong_op, asset_code, use_en, use_operator, client_no,  client_name, other) VALUES ('$brand', '$model', '$serial_number', '$device_type','$room','$cabinet','$start_u','$end_u','$device_status','$device_feature','$bmc_ip','$manage_ip','$yewu_ip','$device_belong','$belong_en','$belong_op','$asset_code','$use_en','$use_operator','$client_no','$client_name', '$other')";

if ($conn->query($sql) === true) {
    echo "设备添加成功";
} else {
    echo "数据添加失败" . "<br/>" . $conn->error;
}
$conn->close();
?>